<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>29.router-link使用和默认路由.html</title>
    <!-- 引入bootstrap css -->


</head>
<body>
<div id="app">
    <!-- 显示路由组件 -->
    <router-link to="/login" tag="button">登录</router-link>
    <router-link to="/reg" tag="span">注册</router-link>
    <router-view></router-view>
</div>

<template id="login">
    <h1>登录页面</h1>
</template>
<template id="reg">
    <h1>注册页面</h1>
</template>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
<script>
    /* 创建模板 */
    const login = {
        template: '#login'
    }
    const register = {
        template: '#reg'
    }
    /* 定义路由 */
    const router = new VueRouter({
        routes:[
            {path:"/",redirect:'/login'},
            {path:"/login",component:login},
            {path:"/reg",component:register}
        ]
    })
    const app = new Vue({
        el: '#app',
        data: {},
        methods: {},
        router

    });
</script>
</body>
</html>